package com.youi.service.impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.youi.common.Common;
import com.youi.common.DelStatus;
import com.youi.dao.StoreDao;
import com.youi.entity.Store;
import com.youi.service.StoreService;

@Service
public class StoreServiceImpl extends BaseServiceImpl<Store> implements StoreService{
		
		private StoreDao storeDao;
		
		@Autowired
		public void setfaultRecordDao(StoreDao storeDao){
			this.storeDao=storeDao;
			super.setBaseDAO(storeDao);
		}

		@Override
		public List<Store> getByStoreList(Map<String, Object> params, Map<String, Object> storeParams,
				Map<String, Object> managerParams, Map<String, Object> sortParams, Integer pageIndex, Integer pageNum,
				Map<String, Object> gtParams, Map<String, Object> ltParams) {
			// TODO Auto-generated method stub
			return storeDao.getByStoreList(params, storeParams, managerParams, sortParams, pageIndex, pageNum, gtParams, ltParams);
		}

		@Override
		public Integer getStoreCount(Map<String, Object> params, Map<String, Object> storeParams,
				Map<String, Object> managerParams, Map<String, Object> gtParams, Map<String, Object> ltParams) {
			// TODO Auto-generated method stub
			return storeDao.getStoreCount(params, storeParams, managerParams, gtParams, ltParams);
		}

		@Override
		public List<Long> getStoreIdList(String code) {
			// TODO Auto-generated method stub
			List<Long> storeIdList=null;
			Map<String, Object> prams=new HashMap<String, Object>();
			prams.put(Common.DELSTATUS, DelStatus.NODEL);
			Map<String, Object> seachParams=new HashMap<String, Object>();
			seachParams.put("code", code);
			List<Store> storeList=storeDao.getByParams(prams, seachParams, null);
			if (storeList!=null&&storeList.size()>0) {
				storeIdList=new ArrayList<Long>();
				for (Store store : storeList) {
					storeIdList.add(store.getId());
				}
				return storeIdList;
			}
			return null;
		}
}